<template>
	<u-button @click="settingMsg">消息订阅</u-button>
</template>

<script>
	export default{
		data(){
			return {}
		},
		onLoad() {
			let that = this;
			/* uni.getSetting({
				widthSubscriptions:true,
				success(res) {
					console.log(res);
					res.authSetting={
						"scope.userInfo":true,
						"scope.userLocation":true,
						"scope.address":true,
						"scope.camera":true,
						"scope.invoice":true,
						"scope.invoiceTitle":true,
						"scope.record":true,
						"scope.werun":true,
						"scope.writePhotosAlbum":true
					}
					res.subscriptionsSetting={
						mainSwitch:true,
						itemSettings:{
							SYS_MSG_TYPE_INTERACTIVE:'accept',
							SYS_MSG_TYPE_RANK:"accept",
						}
					}
					that.settingMsg();
				}
			}) */
			uni.requestSubscribeMessage({
				templIds:[
					'消息模板ids',
					'消息模板ids.....'
				],
				success(res) {
					console.log(res);
					/**
					 * 值包括accept,reject,ban
					 * accept表示用户同意订阅该条id消息模板应用消息
					 * reject表示用户拒绝订阅该条id消息模板应用消息
					 * ban已经被后台封禁
					 * **/
					 if(res.errMsg=='requestSubscribeMessage:ok'){
						 uni.showToast({
						 	title:'订阅成功'
						 })
					 }
				},
				fail(err) {
					console.log(err);
				}
			})
				
		},
		methods:{
			settingMsg(){
				console.log(9999);
				uni.requestSubscribeMessage({
					templIds:[
						'消息模板ids',
						'消息模板ids.....'
					],
					success(res) {
						console.log(res);
						/**
						 * 值包括accept,reject,ban
						 * accept表示用户同意订阅该条id消息模板应用消息
						 * reject表示用户拒绝订阅该条id消息模板应用消息
						 * ban已经被后台封禁
						 * **/
						 if(res.errMsg=='requestSubscribeMessage:ok'){
							 uni.showToast({
							 	title:'订阅成功'
							 })
						 }
					},
					fail(err) {
						console.log(err);
					}
				})
			}
		}
	}
</script>

<style>
</style>